; (function () {
	new Vue({
		el: '#jwkIndstry',
		data: {
			data: [],
			addArr: [],
			selectActiveCode: []
		},
		methods: {
			//获取行业类型
			jwkIndstryDt () {
				hlhttp.get({
					url: 'jwk/company_industrys',
					data: {valid: '#'},
					success: (data) => {
						this.data = data;
					}
				})
			},
			//编辑
			edit (i) {
				if (this.selectActiveCode.indexOf(this.data[i].industryCode) == -1) {
					this.selectActiveCode.push(this.data[i].industryCode)
					return
				}
			},
			//编辑保存
			editSubmit (i) {
				hlhttp.put({
					url: 'jwk/company_industry',
					data: {
						industry_code: this.data[i].industryCode,
						industry_name: this.data[i].industryName ? this.data[i].industryName : '#',
					},
					success: () => {
						hl.toast('操作成功')
						this.selectActiveCode.splice(this.selectActiveCode.indexOf(this.data[i].industryCode), 1)
						this.jwkIndstryDt()
					}
				})
			},
			//删除行业
			del (item) {
				hlhttp.delete({
					url: 'jwk/company_industry?industry_code=' + item.industryCode,
					success: () => {
						hl.toast('操作成功')
						this.jwkIndstryDt()
					}
				})
			},
			//新增
			add () {
				if (this.addArr.length) {
					hl.toast('请先保存当前新增行业')
					return
				}
				this.addArr.push({industryName: ''})
			},
			//新增保存
			addSave () {
				hlhttp.post({
					url: 'jwk/company_industry',
					data: {industry_name: this.addArr[0].industryName},
					success: (data) => {
						hl.toast('新增成功')
						this.jwkIndstryDt()
						this.addArr = [];
					}
				})
			},
			//删除新增行业
			delAddIndustry () {
				this.addArr = []
			},
			//停用/启用企业行业类型
			validSet (i) {
				hlhttp.put({
					url: 'jwk/company_industry/_valid',
					data: {
						industry_code: this.data[i].industryCode,
						opt: this.data[i].valid == 'Y' ? 'N' : 'Y'
					},
					success: () => {
						hl.toast('操作成功')
						this.jwkIndstryDt()
					}
				})
			},
			copyURL (item) {								
				hlhttp.get({
					url: 'configure/copy_url',
					data: {
						function_cate: 'COPYURL_JWK_HY',
						params: item.industryCode
					},
					async:false,
					success: (data) => {
						var Url = document.getElementById("copyInput");
						Url.value = data.copyUrl;
					}
				})

			},
			copyss () {
				var Url = document.getElementById("copyInput");
				Url.select(); // 选择对象
				document.execCommand("Copy"); // 执行浏览器复制命令
				hl.toast('复制成功')
			}
		},
		mounted () {
			this.jwkIndstryDt()
		}
	})
} ())
